#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>

void Swap(int *a,int *b)
{
	int tmp = *a;
	*a = *b;
	*b = tmp;
}
int partSort(int* a, int left,int right)
{
	int keyi = left;
	int i = left, j = right;
	while (i < j)
	{
		while (i < j && a[j] >= a[keyi])
		{
			j--;
		}
		while (i < j && a[i] < a[keyi])
		{
			i++;
		}
		Swap(&a[i], &a[j]);
	}
	Swap(&a[keyi],&a[i]);
	return i;
}
void QuickSort(int* a, int left, int right)
{
	if (left >= right)
		return;
	int pivot = partSort(a, left, right);
	QuickSort(a, left, pivot - 1);
	QuickSort(a, pivot+1, right);
}
int main()
{
	int arr[] = { 12,23,43,14,26,9,36 };
	int n = sizeof(arr) / sizeof(arr[0]);
	QuickSort(arr, 0,n-1);
	for (int i = 0; i < n; i++)
	{
		printf("%d ", arr[i]);
	}
	printf("\n");
	return 0;
}